<!DOCTYPE html>
<html lang="en">
<head>
    <title>面访人员列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        [v-cloak] {
            display: none;
        }
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        body{
            margin: 1px;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: x-small;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
        }

        .table th {
            background: yellow;
        }

        table td {
            padding-top: 5px;
            padding-bottom: 5px;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
            margin-bottom: 20px;
        }


    </style>
</head>
<body>
<section class="content" id="app">
    <div v-cloak style="text-align: center;font-size: x-small;margin: 6px 0">
        <template v-if="visitType==1">面访
            <template v-if="hour<8 && isDay"><br/>(昨日)</template>
        </template>
        <template v-else>
            电访
            <template v-if="isDay"><br/>(昨日)</template>
        </template>
        :目标（{{visitType == 1? sendData.faceTargetInfo.dayTarget:
        sendData.telTargeInfo.dayTarget}}），完成（{{visitType == 1?
        sendData.faceTargetInfo.complete:sendData.telTargeInfo.complete}}）
    </div>
    <table class="table table-hover table-bordered text-center ">
        <thead>
        <tr>
            <th style="width:80px">客户电话</th>
            <th style="width:60px">客户姓名</th>
            <th style="width:60px">客户<br/>微信号</th>
            <th style="width:80px">拜访日期</th>
            <th v-if="visitType == 1">拜访时长</th>
        </tr>
        </thead>
        <tbody>
        <template v-if="visitType==1">
            <tr v-for="(item,i) in sendData.faceTargetDay">
                <td>{{item.tel}}</td>
                <td style="color:#169BD5;cursor: pointer" @click="lookInterview(item,'day')">
                    {{item.name}}
                </td>
                <td>{{item.wechat==""?"-":item.wechat}}</td>
                <td>{{item.date}}</td>
                <template v-if="visitType == 1">
                    <td v-if="item.time!=0">{{item.time}}分</td>
                    <td v-else>
                        {{item.arrivalsTime?item.arrivalsTime:"-"}}/{{item.leaveTime?item.leaveTime:"-"}}
                    </td>
                </template>
            </tr>
        </template>
        <template v-else>
            <tr v-for="(item,i) in sendData.telTargetDay">
                <td>{{item.tel}}</td>
                <td>
                    {{item.name}}
                </td>
                <td>{{item.wechat==""?"-":item.wechat}}</td>
                <td>{{item.date}}</td>
                <td v-if="visitType == 1">{{item.arrivalsTime == ""?"-":item.arrivalsTime
                    }}/{{item.leaveTime ==
                    ""?"-":item.leaveTime }}
                </td>
            </tr>
        </template>
        </tbody>
    </table>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/js/oaApp.js"></script>
<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }

    function isDay(time) {
        //2018-01-01
        if (time.length > 8) {
            return true
        } else {
            return false
        }
    }

    var app = new Vue({
        el: '#app',
        data: {
            userId: getUrlParam('userId'),
            isDay: isDay(getUrlParam('dateTime')),
            visitType: getUrlParam('visitType'),//0电访 1面访
            sendData: {
                telTargetDay: [],
                faceTargetDay: [],
                faceTargetInfo: {dayTarget: "", complete: ""},
                telTargeInfo: {dayTarget: "", complete: ""}
            },
            hour: new Date().getHours(),
        },
        methods: {
            getUrlParam: function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]);
                return null; //返回参数值
            },
            lookInterview: function (item, type) {
                prompt(JSON.stringify(item));
            }
        },
        mounted: function () {
            var that = this;
            this.visitType = this.getUrlParam('visitType')
            var data = {
                userId: this.getUrlParam('userId'),
                dateTime: this.getUrlParam('dateTime'),
                isApp: "1"
            };
            $.ajax({
                url: server.ip + urlConfig.crm.customer.getPeopleByUserId,
                contentType: 'application/json;charset=utf-8',
                type: "POST",
                data: JSON.stringify(data),
                success: function (r) {
                    var res = JSON.parse(r)
                    that.sendData = res.data.sendData
                },
                error: function (e) {
                    alert(e.responseText)
                }
            })
        }
    });
</script>

</body>
</html>